package com.cardone.platform.common.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;


import lombok.Getter;


import lombok.Setter;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import com.cardone.common.dto.PaginationDto;
import com.cardone.common.cache.Caches;
import com.cardone.context.Attributes;
import com.cardone.context.ContextHolder;
import com.cardone.common.util.EntityUtils;
import com.cardone.platform.common.dao.EntityExtendDao;
import com.cardone.platform.common.dto.EntityExtendDto;

/**
 * 实体扩展服务
 *
 * @author yaohaitao
 * 
 */
@Getter 
@Setter
@Transactional(readOnly = true)
public class EntityExtendDefaultService implements EntityExtendService {
	@Override
	@Transactional
	public <P> P saveByIdOrCode(Class<P> mappedClass, EntityExtendDto saveEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).saveByIdOrCode(mappedClass, saveEntityExtend);
	}
	
	@Override
	@Transactional
	public EntityExtendDto saveByIdOrCode(EntityExtendDto saveEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).saveByIdOrCode(EntityExtendDto.class, saveEntityExtend);
	}
	
	@Override
	public <P> P findByCodeOrId(Class<P> mappedClass, EntityExtendDto findEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).findByCodeOrId(mappedClass, findEntityExtend);
	}
	
	@Override
	public Integer readByCodeNqIdForCount(EntityExtendDto readEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).readByCodeNqIdForCount(readEntityExtend);
	}
	
	@Override
	@Transactional
	public int insertByCode(EntityExtendDto insertEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).insertByCode(insertEntityExtend);
	}
	
	@Override
	@Transactional
	public int updateByCode(EntityExtendDto updateEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).updateByCode(updateEntityExtend);
	}

	@Override
	@Transactional
	public int deleteByIds(EntityExtendDto deleteEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).deleteByIds(deleteEntityExtend);
	}

	@Override
	public <P> P findById(Class<P> mappedClass, EntityExtendDto findEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).findById(mappedClass, findEntityExtend);
	}

	@Override
	public <P> List<P> findListByLikeCode(Class<P> mappedClass, EntityExtendDto findListEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).findListByLikeCode(mappedClass, findListEntityExtend);
	}

	@Override
	public <P> List<P> findList(Class<P> mappedClass) {
		return ContextHolder.getBean(EntityExtendDao.class).findList(mappedClass);
	}

	@Override
	public <P> PaginationDto<P> paginationByLikeCode(Class<P> mappedClass, EntityExtendDto paginationEntityExtend) {
		return ContextHolder.getBean(EntityExtendDao.class).paginationByLikeCode(mappedClass, paginationEntityExtend);
	}
}